import type { IQuery, TableConfig } from '@/api/config/types';
import { QUERY_SCOPE } from '@/enum/system';

export const useQuery = <T>(config?: Partial<IQuery<T>>): Ref<IQuery<T>> => {
  let obj: IQuery = {
    pageNum: 1,
    pageSize: 15,
    orderByColumn: 'create_time',
    isAsc: 'desc',
    scope: QUERY_SCOPE.ALL,
  };
  let result: any = Object.assign(obj, config);
  // @ts-ignore
  return ref<IQuery<T>>(result);
};
export const useTable = <T>(config?: Partial<TableConfig<T>>) => {
  let obj: TableConfig<T> = {
    data: [],
    loading: false,
    keys: [],
    rowKey: '',
    moduleName: '',
  };
  return ref<TableConfig<T>>(Object.assign(obj, config));
};
